package com.github.kezhenxu94.playground.java.interview.netease;

import java.util.Scanner;

public class NetEaseSumOfDigits {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int sumOfDigitsOfC = sumOfDigits(c);
		int minDiffer = Integer.MAX_VALUE;
		int result = 0;
		for (int i = a; i <= b; i++) {
			int differ = sumOfDigits(i) - sumOfDigitsOfC;
			differ = differ < 0 ? -differ : differ;
			if (differ < minDiffer) {
				minDiffer = differ;
				result = i;
			}
		}
		System.out.println(result);
		sc.close();
	}

	private static int sumOfDigits(int n) {
		int sum = 0;
		while (n > 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}
}
